package main

import (
	"fmt"
	"github.com/gomodule/redigo/redis"
)

func main() {
	con, err := redis.Dial("tcp", "127.0.0.1:6379" /*,redis.DialUsername("")*/)
	if err != nil {
		fmt.Println("redis conn error is ", err)
		return
	}
	defer con.Close()
	fmt.Println("redis conn success")
	_, err1 := con.Do("Set", "name", "zw")
	if err1 != nil {
		fmt.Println("redis Set error is ", err)
		return
	}

	// 返回结果为string
	res, err1 := redis.String(con.Do("Get", "name"))
	if err1 != nil {
		fmt.Println("redis Get error is ", err)
		return
	}
	fmt.Println("redis Get result is ", res)
}
